#include "clientHead/order_analyse.h"
#include "clientHead/trans_file.h"
// netfd: 交换数据的那个socket的文件描述
// type: 火车信息的类型
// data: 指向火车信息的字符数组指针
// len: 表示火车信息的长度

//从客户端发送数据
int sendTrain(int sockfd, order_train_t* orderTrain){
    ssize_t sret= send(sockfd, &orderTrain->order_len, sizeof(TokenType_), 0);
    sret = send(sockfd, &orderTrain->data_len, sizeof(int), 0);
    sret = send(sockfd, orderTrain->train_data, orderTrain->data_len, 0);
    return sret; // 执行信息
}


//接收数据
int recvTrain(int sockfd, order_train_t* train){
    bzero(train, sizeof(order_train_t));
    ssize_t sret = recv(sockfd, &train->order_len, sizeof(TokenType_), 0);
    printf("第一次%d\n", train->order_len);
    sret = recv(sockfd, &train->data_len, sizeof(int), 0);
    printf("第二次%d\n", train->data_len);
    sret = recv(sockfd, train->train_data, train->data_len, 0);
    printf("第三次%s\n", train->train_data);
    return sret;
}

